<?php

declare(strict_types=1);

namespace App\Command;

use App\Service\CommodityService\SupplierCommodityCainiaoPullLogService;
use Hyperf\Command\Command as HyperfCommand;
use Hyperf\Command\Annotation\Command;
use Psr\Container\ContainerInterface;
use Symfony\Component\Console\Input\InputArgument;

/**
 * @Command
 */
class SupplierCommodityCainiaoPullTask extends HyperfCommand
{
    /**
     * @var ContainerInterface
     */
    protected $container;

    public function __construct(ContainerInterface $container)
    {
        $this->container = $container;
    
        parent::__construct('SupplierCommodityCainiaoPullTask');
    }
    
    public function configure()
    {
        parent::configure();
        $this->setDescription('拉取菜鸟供应商商品');
    }
    
    public function handle()
    {
        $args = $this->input->getArguments();
        $SupplierID = $args['SupplierID'] ?? 0 ;
        $res = SupplierCommodityCainiaoPullLogService::instance()->runTask($SupplierID);
        $this->line(json_encode($res,JSON_UNESCAPED_UNICODE), 'info');
    }

    protected function getArguments()
    {
        return [
            ['SupplierID', InputArgument::OPTIONAL, '单个菜鸟供应商ID']
        ];
    }
}
